package org.lex.ftplist.util;

import java.io.IOException;
import java.net.SocketException;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPClientConfig;
import org.lex.ftplist.core.FtpUrl;

public class FtpUtils {
	public static FTPClient connect(FtpUrl url) throws SocketException, IOException {
		return connect(url.host, url.port, url.user, new String(url.password));
	}

	public static FTPClient connect(String host, int port, String user, String password) throws SocketException, IOException {
		FTPClientConfig cfg = new FTPClientConfig();
		FTPClient ftp = new FTPClient();
		ftp.setControlEncoding("gbk");
		ftp.configure(cfg);
		ftp.connect(host, port);
		ftp.login(user, password);
		return ftp;
	}

	public static String encodeFTPURL(FtpUrl ftpURL) {
		return null;
	}

	public static FtpUrl decodeFTPURL(String str) {
		return null;
	}
}
